package exam.test6;

import java.util.Scanner;

public class Rechtangle {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("Enter width: ");
        int width = Integer.parseInt(scanner.nextLine());

        System.out.print("Enter height: ");
        int height = Integer.parseInt(scanner.nextLine());

        double eps = 1e-10;
        double area = width * height * 1D / 2;
        if (area - Math.floor(area) < eps) {
            System.out.printf("A rechtangle of width %s and width %s has area %.0f.\n", width, height, area);
        } else {
            System.out.printf("A rechtangle of width %s and width %s has area %.5f.\n", width, height, area);
        }

        double perimeter = width + 2 * Math.sqrt(height * height + (1D * width  / 2 * width  / 2));
        if (perimeter - Math.floor(perimeter) < eps) {
            System.out.printf("A rechtangle of width %s and width %s has perimeter %.0f.\n", width, height, perimeter);
        } else {
            System.out.printf("A rechtangle of width %s and width %s has perimeter %.5f.\n", width, height, perimeter);
        }

    }
}
